#pragma once
#include<iostream>
#include<string>
#define Change(v)(struct sockaddr*)(v)
#define Die(code) do{exit(code);}while(0)

enum
{
    SCOKET_ERR=1,
    BIND_ERR,
    USAGE_ERR,
    Listen_ERR
};

class Command
{
public:
    std::string Execute(std::string cmdstr)
    {
        return cmdstr;
    }
};

int gdefaultsockfd = -1;

bool Oneline_read(std::string &str, std::string *out, const std::string &sep)
{
    auto pos =str.find(sep);
    if(pos == std::string::npos)
    {
        return false;
    }
    *out = str.substr(0, pos);
    str = str.substr(pos + sep.size());
    return true;
}

bool SplitString(const std::string &header, const std::string &sep, std::string *key, std::string *value)
{
    auto pos=header.find(sep);
    if(pos == std::string::npos)
    {
        return false;
    }
    *key = header.substr(0, pos);
    *value = header.substr(pos + sep.size());
    return true;
}